Crate rlg

source ·
Expand description

A Rust library that implements application-level logging with a simple, readable output format

Rust

Rust Crates.io Lib.rs GitHub License

Overview

RustLogs (RLG) is a library that implements application-level logging in a simple, readable output format. The library provides logging APIs and various helper macros that simplify many common logging tasks.

Features

  • Supports many log levels: ALL, DEBUG, DISABLED, ERROR, FATAL, INFO, NONE, TRACE, VERBOSE and WARNING,
  • Provides structured log formats that are easy to parse and filter,
  • Compatible with multiple output formats including:
    • Common Event Format (CEF),
    • Extended Log Format (ELF),
    • Graylog Extended Log Format (GELF),
    • JavaScript Object Notation (JSON),
    • NCSA Common Log Format (CLF),
    • W3C Extended Log File Format (W3C),
    • and many more

Usage

  • serde: Enable serialization/deserialization via serde

Modules

  • The macros module contains functions for generating macros.

Macros

  • Conditional debug logging Logs if debug_enabled feature flag set
  • Macro for error log with default format
  • Macro for info log with default session id and format Usage: let log = macro_info_log!(time, component, description);
  • Macro to create a new log easily Usage: let log = macro_log!(session_id, time, level, component, description, format);
  • Async log message to file Usage: let result = macro_log_to_file!(log);
  • Print log to stdout Usage: macro_print_log!(log);
  • Set log format if not already defined Usage: macro_set_log_format_clf!(log);
  • Macro for warn log

Structs

  • The Log struct provides an easy way to log a message to the console. It contains a set of defined fields to create a simple, log message with a readable output format.

Enums

  • An enumeration of the different log formats that can be used.
  • Implements Log to log a message to the console with a simple, readable output format.